package com.zabra.zl.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;

import com.zabra.zl.R;
import com.zabra.zl.ui.login.LoginActivity;

public class ShowDialogUtils {

    public static void restLoginDialog(Activity activity) {
        final AlertDialog builder = new AlertDialog.Builder(activity).create();
        LayoutInflater layoutInflater = activity.getLayoutInflater();
        View view = layoutInflater.inflate(R.layout.dialog_timeout, null);
        builder.setView(view);
        builder.setCancelable(false);
        builder.show();
        SharedPreferencesUtil.getInstance(activity).putSP("token", "");
        SharedPreferencesUtil.getInstance(activity).putSP("debtorid", "");
        view.findViewById(R.id.tv_sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(activity, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                activity.startActivity(intent);
                activity.finish();
                builder.dismiss();
            }
        });
    }
}
